<template>
	<div>
		<el-card class="!border-none pt-4" shadow="never">
			<el-form class="ls-form el-set-form" :model="paramster" inline>
				<el-form-item label="标题">
					<el-input class="w-[240px]" placeholder="请输入" v-model="paramster.title" clearable />
				</el-form-item>
				<el-form-item>
					<el-button class="main-color1 w-[76px] h-[36px]" @click="resetting">重置</el-button>
					<el-button class="w-[76px] h-[36px]" color="#0054A6" type="primary" @click="getLists">查询</el-button>
				</el-form-item>
			</el-form>
		</el-card>
		<el-card class="!border-none pt-4 mt-[20px]" shadow="never">
			<div class="text-right">
				<el-button class="w-[76px] h-[36px]" color="#0054A6" type="primary">
					<router-link :to="{
							path: getRoutePath('basicSettings.basicSettings/messageAdd'),
							query: {
								id: '3'
							}
						}">
						<span>添加</span>
					</router-link>
				</el-button>
			</div>
			<el-table class="mt-[20px]" size="large" :data="messageList"
				:header-cell-style="{'background':'#0054A6','color':'#FFB400','line-height':'52px','padding':'14px 0'}"
				:cell-style="{'color':'#0054A6','padding':'20px 0'}">
				<el-table-column label="标题内容" prop="title" align="center">
					<template #default="{ row }">
						<el-button type="primary" link>
							<router-link :to="{
					                path: getRoutePath('basicSettings.basicSettings/detail'),
					                query: {
					                    id: row.id
					                }
					            }">
								<span class="main-color">{{row.title}}</span>
							</router-link>
						</el-button>
					</template>
				</el-table-column>
				<el-table-column label="时间" prop="create_time" align="center" />
				<el-table-column label="操作" fixed="right" align="center">
					<template #default="{ row }">
						<el-button type="primary" link>
							<router-link :to="{
									path: getRoutePath('basicSettings.basicSettings/messageAdd'),
									query: {
										id: '3'
									}
								}">
								<span class="main-color1">编辑</span>
							</router-link>
						</el-button>
						<el-button type="primary" link @click="handleDelete(row.id)">
							<span class="main-color1">删除</span>
						</el-button>
					</template>
				</el-table-column>
			</el-table>
			<div class="p-[20px] v-flex v-row-right">
				<el-pagination background layout="prev, pager, next" :default-page-size="paramster.page_size"
					:current-page="paramster.page_no" :total="total" @current-change="handleCurrentChange"/>
			</div>
		</el-card>
	</div>
</template>

<script lang="ts" setup>
	import { getRoutePath } from '@/router'
	import feedback from '@/utils/feedback'
	import { GetMessage } from '@/api/basicSettings'
	const paramster = reactive({//列表传参
		page_no: 1,//页码
		page_size: 10,//数量
		is_read: '',//0-未读，1-已读，不传-全部
		title: '',//标题搜索
	})
	const total = ref('')//总页码
	const messageList = ref([])//消息列表
	const handleDelete = async (id : number) => {
		await feedback.confirm('确定要删除？')
		// await menuDelete({ id })
		// getLists()
	}
	// 获取消息列表
	const getLists = async () => {
		await GetMessage(paramster).then(res => {
			messageList.value = res.lists
			total.value = res.total
		})
	}
	getLists()
	// 重置
	const resetting = () => {
		paramster.title = ""
		getLists()
	}
	// 分页
	const handleCurrentChange = (val: number) => {
		paramster.page_no = val
		getLists()
	}
</script>

<style scoped lang="scss">
	.el-set-form:deep() .el-form-item__label {
		color: var(--el-text-color-main);
		height: 36px;
		line-height: 36px;
	}

	.el-set-form:deep() .el-input__inner {
		height: 36px;
	}

	.el-set-form:deep() .el-input__inner::placeholder {
		color: var(--el-text-color-main);
	}

	.el-tabs__item.is-active {
		color: var(--el-text-color-main);
		font-weight: bold;
	}

	.el-tabs__nav-wrap::after {
		background-color: #F5F5F5;
	}

	.el-tabs__active-bar {
		background-color: var(--el-text-color-main);
	}

	:deep() .el-pagination.is-background .el-pager li.is-active {
		background-color: var(--el-text-color-main);
	}
</style>